//
//  CommentTableViewCell.m
//  花花时尚
//
//  Created by zhang on 15/10/7.
//  Copyright (c) 2015年 ggs. All rights reserved.
//

#import "CommentTableViewCell.h"
#import "Define.h"
#import "CommentModel.h"
#import "UIImageView+WebCache.h"

@interface CommentTableViewCell ()

@property (nonatomic, retain)UIImageView *headPic;
@property (nonatomic, retain)UILabel *userName;
@property (nonatomic, retain)UILabel *comments;
@property (nonatomic, retain)UILabel *upDateTime;

@end

@implementation CommentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView
{
    self.headPic = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 40, 40)];
    self.headPic.layer.cornerRadius = self.headPic.frame.size.width / 2;
    self.headPic.layer.masksToBounds = YES;
    self.headPic.layer.cornerRadius = 20;
    //    self.headPic.backgroundColor = [UIColor blackColor];
    [self.contentView addSubview:self.headPic];
    [self.headPic release];
    
    self.userName = [[UILabel alloc] initWithFrame:CGRectMake(self.headPic.frame.size.width + self.headPic.frame.origin.x + 5, self.headPic.frame.origin.y + 15, 100, 15)];
    //    self.userName.backgroundColor = [UIColor blackColor];
    self.userName.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.userName];
    [self.userName release];
    
    self.comments = [[UILabel alloc] initWithFrame:CGRectMake(self.headPic.frame.origin.x, self.headPic.frame.origin.y + self.headPic.frame.size.height + 10, SCREEN_WIDTH - 20, 50)];
    self.comments.numberOfLines = 0;
    //    self.comments.backgroundColor = [UIColor blackColor];
    self.comments.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.comments];
    [self.comments release];
    
    self.upDateTime = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 80, self.comments.frame.size.height + self.comments.frame.origin.y + 5, 100, 15)];
    //    self.upDateTime.backgroundColor = [UIColor blackColor];
    self.upDateTime.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.upDateTime];
    [self.upDateTime release];
}
/*
 * 赋值
 */
- (void)setValueWith:(CommentModel *)comment height:(CGFloat)height
{
    [self.headPic sd_setImageWithURL:[NSURL URLWithString:comment.userHeadImg] placeholderImage:[UIImage imageNamed:@"user_holder.png"]];
    self.userName.text = comment.userName;
    self.comments.text = comment.content;
    self.upDateTime.text = comment.dateCreated;
    
    
    self.comments.frame = CGRectMake(self.headPic.frame.origin.x, self.headPic.frame.origin.y + self.headPic.frame.size.height + 10, SCREEN_WIDTH - 20, height);
    self.upDateTime.frame = CGRectMake(SCREEN_WIDTH - 80, self.comments.frame.size.height + self.comments.frame.origin.y, 100, 15);
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
